package com.smart.service.impl;

import java.util.Map;
import java.util.List;
import java.util.HashMap;
import java.util.ArrayList;
import javax.annotation.Resource;
import com.smart.service.SsWorkService;
import com.smart.service.AttendanceService;
import com.smart.service.MainRecordsService;
import com.smart.service.SiteInspectionService;
import com.smart.service.StatisticalService;
import org.springframework.stereotype.Service;

/**
 * @author lgb
 * @date 2020年7月2日 下午7:26:24
 * Copyright (C) 深圳工勘科技
 * @说明: 统计管理
 **/
@Service
public class StatisticalServiceImpl implements StatisticalService{

	@Resource
	private AttendanceService attendanceService;
	@Resource
	private SsWorkService ssWorkService;
	@Resource
	private MainRecordsService mainRecordsService;
	@Resource
	private SiteInspectionService siteInspectionService;
	@Override
	public List<Map<String,Object>> attendanceStatistical() {
		List<Map<String,Object>> data = new ArrayList<>();
		String[] xAxis = {"考勤打卡","作业进度","保养记录","工地巡检","车辆巡检"};
		String[][] xAxisName={{"已打卡","未打卡"},{"已审核","未审核"},
				{"已审核","未审核"},{"正常","异常"},{"正常","异常"}};
		//日统计
		Integer[] ssAttendance = attendanceService.statisticalSsWork(1);
		Integer[] ssWork = ssWorkService.statisticalSsWork(1);
		Integer[] mainRecord = mainRecordsService.statisticalSsWork(1);
		Integer[] siteInspect= siteInspectionService.statisticalSsWork(1);
		Integer[] series1 = {ssAttendance[0],ssWork[0],mainRecord[0],siteInspect[0],0};
		Integer[] series2 = {ssAttendance[1],ssWork[1],mainRecord[1],siteInspect[1],0};
		Map<String,Object> map1 = new HashMap<>();
		map1.put("title","当日统计");
		map1.put("xAxis",xAxis);
		map1.put("xAxisName",xAxisName);
		map1.put("series1",series1);
		map1.put("series2",series2);
		data.add(map1);

		//周统计
		Integer[] ssAttendance1 = attendanceService.statisticalSsWork(2);
		Integer[] ssWork1 = ssWorkService.statisticalSsWork(2);
		Integer[] mainRecord1 = mainRecordsService.statisticalSsWork(2);
		Integer[] siteInspect1= siteInspectionService.statisticalSsWork(2);
		Integer[] series11 = {ssAttendance1[0],ssWork1[0],mainRecord1[0],siteInspect1[0],0};
		Integer[] series21 = {ssAttendance1[1],ssWork1[1],mainRecord1[1],siteInspect1[1],0};
		Map<String,Object> map2 = new HashMap<>();
		map2.put("title","本周统计");
		map2.put("xAxis",xAxis);
		map2.put("xAxisName",xAxisName);
		map2.put("series1",series11);
		map2.put("series2",series21);
		data.add(map2);

		//月统计
		Integer[] ssAttendance2 = attendanceService.statisticalSsWork(3);
		Integer[] ssWork2 = ssWorkService.statisticalSsWork(3);
		Integer[] mainRecord2 = mainRecordsService.statisticalSsWork(3);
		Integer[] siteInspect2= siteInspectionService.statisticalSsWork(3);
		Integer[] series12 = {ssAttendance2[0],ssWork2[0],mainRecord2[0],siteInspect2[0],0};
		Integer[] series22 = {ssAttendance2[1],ssWork2[1],mainRecord2[1],siteInspect2[1],0};
		Map<String,Object> map3 = new HashMap<>();
		map3.put("title","本月统计");
		map3.put("xAxis",xAxis);
		map3.put("xAxisName",xAxisName);
		map3.put("series1",series12);
		map3.put("series2",series22);
		data.add(map3);
		return data;
	}

	
	
	
}